package com.zijing2333.adaptivescheduling.criticalNodeJudgment;

import android.util.Log;

import com.zijing2333.adaptivescheduling.ChannelManager;
import com.zijing2333.adaptivescheduling.SwitcherManager.SwitchTaskInfo;
import com.zijing2333.adaptivescheduling.SwitcherManager.TaskInfoManager;
import com.zijing2333.adaptivescheduling.SwitcherManager.utils.NetworkUtil;
import com.zijing2333.servicerunner.TaskInfo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Executors;

public final class JudgeKeyNode {
    private static final String TAG = "fun_JudgeKeyNode";
    private final int priority;


    public JudgeKeyNode(){
        /*
        DataReader reader  = new DataReader("localhost", 4001);
        List<HashMap<String, Object>> TaskIdMapList = reader.getTaskPriorities();//读取资源视图
        // 先遍历list中的所有map
        // 先遍历list中的所有map
        List<Integer> intList = new ArrayList<>();
        for (HashMap<String, Object> map : TaskIdMapList) {
            // 再遍历map中所有的value，并将其强制转为int类型
            for (Object value : map.values()) {
                if (value instanceof Integer) { // 判断value是否是Integer类型
                    intList.add((Integer) value); // 将其强制转为int类型并添加到intList中
                }
            }
        }
        // 对intList进行从高到低的排序
        Collections.sort(intList, Collections.reverseOrder());
        // 取出前30%左右的这个数据
        int size30Percent = (int) (intList.size() * 0.3);
        // 输出结果
        priority =intList.get(size30Percent-1);

         */
        this.priority = 10;
    }


    public  boolean judge(int p){
        Log.d(TAG, "p:"+p+"   priority:"+priority);
        if (p>priority){
            return true;
        }
        return false;
    }

    //    public static boolean judge(SwitchTaskInfo switchTaskInfo){ //进行是否是关键节点的判断
//        int p = switchTaskInfo.getPriority();
//        Log.d(TAG, "p: "+p +"   "+ "priority:"+priority);
//        if (p>priority){
//            return true;
//        }
//        return false;
//    }
//    public static boolean judge(String taskId){
//        int p= TaskInfoManager.getInstance().getJsMap().get(taskId).getPriority();
//        if (p>priority){
//            return true;
//        }
//        return false;
//    }

}
